public class Solution537 {
    public String complexNumberMultiply(String num1, String num2) {
        int[] f1=deal(num1);
        int[] f2=deal(num2);
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append(f1[0]*f2[0]-f1[1]*f2[1]);
        stringBuilder.append('+');
        stringBuilder.append(f1[0]*f2[1]+f1[1]*f2[0]);
        stringBuilder.append('i');
        return stringBuilder.toString();
    }

    int[] deal(String num){
        int[] f=new int[2];
        int index=num.indexOf('+');
        f[0]=Integer.parseInt(num.substring(0,index));
        f[1]=Integer.parseInt(num.substring(index+1,num.length()-1));
        return f;
    }

    public static void main(String[] args) {
        System.out.println(new Solution537().complexNumberMultiply("1+1i","1+1i"));
    }
}
